<!DOCTYPE html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>ITSM</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="keywords" content="ITSM"/>
    <meta name="description" content="ITSM"/>
    <link rel="stylesheet" href="assets/css/quick.css">
    <!--<link rel="stylesheet" href="js/raty-2.8.0/lib/jquery.raty.css">-->
    <!--<link rel="stylesheet" href="js/jquery-tanchuceng-141202211421/css/css.css">-->
    <link rel="stylesheet" href="css/addons.css">
    <!--[if ie 6]>
    <link rel="stylesheet" href="assets/css/ie6.css">
    <![endif]-->
    <!--[if lte IE 7]>
    <script src="js/json2.js"></script>
    <![endif]-->
    <!--[if lt IE 9]>
    <script src="assets/js/html5.js"></script>
    <![endif]-->
    <script src="js/plupload-2.3.1/js/plupload.full.min.js"></script>
    <script src="assets/js/jquery-1.7.1.min.js"></script>
    <!--<script src="js/raty-2.8.0/lib/jquery.raty.js"></script>-->
    <!--<script src="assets/js/quick.js"></script>-->
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <style type="text/css">
        .self_button {
            color: #ffffff;
            text-decoration: none;
            cursor: pointer
        }

        .self_button:hover {
            color: #DEDEDE;
            text-decoration: none;
            font-weight: bold;
        }

        ul li{
            list-style-type:none;
        }

        .comment {
            font-size: 30px;
            color: darksalmon;
        }

        .comment li {
            float: left;
            cursor: pointer;
        }

        ul {
            list-style: none;
        }

        .pjbutton{
            margin-right: 8px;height: 20px;display: inline-block;line-height: 20px;padding: 5px 13px;border: 1px solid #ccc;border-radius: 4px;cursor: pointer;
        }

        .pjbutton.active{
            background-color: #00CCFF;
        }

        .alertShow{
            display: inline-block;
            top: 0;
            position: absolute;
            margin-top: 0;
            height: auto;
        }
    </style>

</head>
<body style="background: #ffffff url(imgs/bg.png) repeat-x;">

<div class="heading" style="background: #56D0FF repeat-x;height: 120px;">
    <div class="wrapper" style="margin-top: -30px;">
        <h1><img src="imgs/logo2.png"></h1>
    </div>
</div>
<div class="wrapper" style="min-height: 800px;">
    <div class="row">
        <div class="col3">
            <ul class="sidebar center" style="cursor: pointer;">
                <li class="selected"><a rel="popup" onclick="reloadPage();">我的工单</a></li>
                <li><a rel="popup" onclick="showAddGd();">申请服务</a></li>
                <li><a rel="popup" onclick="getSuggestionList();">意见反馈</a></li>
                <li><a rel="popup" onclick="loginOut();">注销登录</a></li>
            </ul>
        </div>
        <div class="col9">
            <div class="part" id="#gd">
                <table width="100%" border="0" class="table bordered center zebra">
                    <thead>
                    <tr class="strong">
                        <td>工单编号</td>
                        <td>工单类型</td>
                        <td>提交时间</td>
                        <td>处理人</td>
                        <td>处理进度</td>
                        <td>操作</td>
                    </tr>
                    </thead>
                    <tbody id="detailList">
                    <tr><td colspan="6">数据加载中...</td></tr>
                    <!--<tr>-->
                        <!--<td>CQ-1700124832</td>-->
                        <!--<td>会议系统服务</td>-->
                        <!--<td>2017-11-24 17:13:43</td>-->
                        <!--<td>服务台团队</td>-->
                        <!--<td>分派工单</td>-->
                        <!--<td><a href="#alertDetail" rel="popup">查看</a>&nbsp;<a href="#">催单</a></td>-->
                    <!--</tr>-->
                    <!--<tr>-->
                        <!--<td>CQ-1700124832</td>-->
                        <!--<td>会议系统服务</td>-->
                        <!--<td>2017-11-24 17:13:43</td>-->
                        <!--<td>服务台团队</td>-->
                        <!--<td>处理完成</td>-->
                        <!--<td><a href="#">查看</a>&nbsp;<a href="#evaluate" rel="popup">评价</a>&nbsp;<a href="#">催单</a></td>-->
                    <!--</tr>-->
                    <!--<tr>-->
                        <!--<td>CQ-1700124832</td>-->
                        <!--<td>会议系统服务</td>-->
                        <!--<td>2017-11-24 17:13:43</td>-->
                        <!--<td>服务台团队</td>-->
                        <!--<td>分派工单</td>-->
                        <!--<td><a href="#">查看</a>&nbsp;<a href="#">催单</a></td>-->
                    <!--</tr>-->
                    </tbody>
                </table>
            </div>

            <!--工单详情 start-->
            <div class="popup" id="alertDetail">
                <div class="head"> 工单详情-<span id="gdTitle">其它服务</span>
                    <del>×</del>
                </div>
                <div class="body">
                    <table width="100%" border="0" class="table bordered center">
                        <tbody>
                        <tr>
                            <td>事件单号</td>
                            <td id="gdID">CQ-XXXXXXX</td>
                            <td>状态</td>
                            <td id="gdState">XXXXXXX</td>
                            <td>用户名</td>
                            <td id="gdUser">XXXXXXX</td>
                        </tr>
                        <tr>
                            <td>部门</td>
                            <td id="gdDepartment">XXXXXXX</td>
                            <td>电话</td>
                            <td id="gdTel">XXXXXXX</td>
                            <td>邮件</td>
                            <td id="gdEmail">XXXXXXXXXX</td>
                        </tr>
                        </tbody>
                    </table>
                    <h2>工单内容:<span id="gdContent">xxxxxxxxxx</span></h2>
                    <div style="padding:10px 10px 0 10px; font-size: 18px;" id="packeg">
                    </div>
                    <div style="padding:10px 10px 0 10px">
                        <img id="wexinDownloadImg" src="" style="max-width:100%;"/>
                    </div>
                    <div style="border: solid 1px #333;margin: 20px;font-size: 14px; list-style:none; ">
                        <ul id="gdProcess">
                            <li><h3>处理过程</h3>
                            </li>
                            <li>提交服务台分派 秦鹏XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX <br>
                                2017-11-24 17:13:45
                            </li>
                        </ul>
                    </div>

                </div>
            </div>
            <!--工单详情 end-->
            <!--新增工单 start-->
            <div class="popup" id="addNew">
                <div class="head"> 新增工单
                    <del>×</del>
                </div>
                <div class="body">
                    <table width="100%" border="0" class="table bordered center">
                        <tbody>
                        <tr>
                            <td>事件单号</td>
                            <td >--</td>
                            <td>状态</td>
                            <td>新增</td>
                            <td>用户名</td>
                            <td id="addUser">XXX</td>
                        </tr>
                        <tr>
                            <td>部门</td>
                            <td id="addDepartment">XXXXXXX</td>
                            <td>电话</td>
                            <td id="addTel">xxxxx</td>
                            <td>邮件</td>
                            <td id="addEmail">XXXXXXXXXX</td>
                        </tr>
                        </tbody>
                    </table>
                    <h2>服务描述:</h2>
                    <textarea style="width:520px;" rows="6" id="description" placeholder="请描述您所选择的服务请求的具体信息以及用户所在办公地点。"></textarea>
                    <h2 id="addressTitle" class="">办公地点:</h2>
                    <textarea class="" style="width:520px;" rows="6" id="descriptionAddress" placeholder="请输入您所在办公地点。"></textarea>

                    <div style="font-size: 14px;">
                        <div class="row">
                            <div class="col3">
                                <label style="font-size: 18px;">
                                    <input type="radio" checked name="category" value="SERVICEREQ_CATEGORY_10">
                                    <i class="icon icon-folder-close"></i>&nbsp;桌面支持服务
                                    <i class="radio-icon ion-android-radio-button-off "></i>
                                </label>
                            </div>
                            <div class="col3">
                                <label style="font-size: 18px;">
                                    <input type="radio" name="category" value="SERVICEREQ_CATEGORY_20">
                                    <i class="icon icon-phone-alt"></i>&nbsp;会议支持服务
                                    <i class="radio-icon ion-android-radio-button-off "></i>
                                </label>
                            </div>
                            <div class="col3">
                                <label style="font-size: 18px;">
                                    <input type="radio" name="category" value="SERVICEREQ_CATEGORY_40">
                                    <i class="icon icon-hdd"></i>&nbsp;应用系统服务
                                    <i class="radio-icon ion-android-radio-button-off "></i>
                                </label>
                            </div>
                            <div class="col3">
                                <label style="font-size: 18px;">
                                    <input type="radio" name="category" value="SERVICEREQ_CATEGORY_50">
                                    <i class="icon icon-retweet"></i>&nbsp;其他服务
                                    <i class="radio-icon ion-android-radio-button-off "></i>
                                </label>
                            </div>
                        </div>

                        <div style="margin-top:20px;font-size: 18px; cursor: pointer;">
                            <!--<input type="file" accept="*" onchange="uploadFile(this)" style="z-index:999;position: absolute;left: 0;width: 100%;cursor:pointer;right: 0;height:25px;opacity: 0;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);">-->
                            <!--<a href="javascript:void(0)">-->
                                <!--上传附件-->
                                <!--<i class="icon icon-floppy-open"></i>-->
                            <!--</a>-->
                            <div id="container">
                                <a id="pickfiles" href="javascript:;">选择文件</a>&nbsp;
                                <!--<a id="uploadfiles" href="javascript:;">上传文件</a>-->
                            </div>
                            <div id="filelist">正在初始化上传组件,请稍后...</div>
                        </div>

                        <!--<div id="wexinUploadImgContainer" class="item" style="display:none">-->
                            <!--<button class="button button-small button-assertive" onclick="delUploadFile();" style="display:inline-block;float: right; z-index: 999;">删除</button>-->
                            <!--<a href="#" id="wexinUploadImg" target="_blank"></a><br/>-->
                        <!--</div>-->

                    </div>
                </div>
                <div class="center" style="margin: 20px;">
                    <button class="button" onclick="subGd();" style="background-color: #56D0FF; color:#fff;">
                        提交
                    </button>
                </div>
            </div>
            <!--新增工单 end-->
            <!--工单评价 start-->
            <div class="popup" id="evaluate" style="font-size: 16px;">
                <div class="head"> 工单评价
                    <del>×</del>
                </div>
                <div class="body">
                    <div class="scroll" style="transform: translate3d(0px, 0px, 0px) scale(1);">
                        <div class="list">
                            <div style="margin:20px 0 0 10px">服务台：
                                <ul class="comment" id="fwtComment">
                                <li>☆</li>
                                <li>☆</li>
                                <li>☆</li>
                                <li>☆</li>
                                <li>☆</li>
                                </ul>&nbsp;&nbsp;满意请给5分哦~ <strong></strong></div>
                            <div style="margin:15px 0px 20px 10px">工程师：
                                <ul class="comment" id="gcsComment">
                                    <li>☆</li>
                                    <li>☆</li>
                                    <li>☆</li>
                                    <li>☆</li>
                                    <li>☆</li>
                                </ul>&nbsp;&nbsp;满意请给5分哦~ <strong></strong></div>
                            <div style="font-size: 12px;padding: 20px 10px;border-top: 1px solid #ddd;">
                                <span class="pjbutton">非常满意</span>
                                <span class="pjbutton">响应及时</span>
                                <span class="pjbutton">态度好，服务棒！</span>
                            </div>
                            <label class="item">
                                <textarea id="pjnr" placeholder="请输入您的意见或建议，帮助我们提供更高的服务体验" rows="6" style="width: 500px;"></textarea>
                            </label>
                            <label class="padding" style="text-align: center;">
                                <button id="subPj" class="button blue" gdId = "" onclick="subEvaluate();">提交</button>
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <!--工单评价 end-->
            <!--查看评价 start-->
            <div class="popup" id="checkEvaluate" style="font-size: 16px;">
                <div class="head"> 工单评价
                    <del>×</del>
                </div>
                <div class="body">
                    <div class="scroll" style="transform: translate3d(0px, 0px, 0px) scale(1);">
                        <div class="list">
                            <div style="margin:20px 0 0 10px">服务台：
                                <ul class="comment" id="fwtCommentView">
                                    <li>☆</li>
                                    <li>☆</li>
                                    <li>☆</li>
                                    <li>☆</li>
                                    <li>☆</li>
                                </ul>&nbsp;&nbsp;满意请给5分哦~ <strong></strong></div>
                            <div style="margin:15px 0px 20px 10px">工程师：
                                <ul class="comment" id="gcsCommentView">
                                    <li>☆</li>
                                    <li>☆</li>
                                    <li>☆</li>
                                    <li>☆</li>
                                    <li>☆</li>
                                </ul>&nbsp;&nbsp;满意请给5分哦~ <strong></strong></div>
                            <label class="item">
                                <textarea id="pjnrView" rows="6" readonly style="width: 500px;"></textarea>
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <!--查看评价 end-->
            <!--意见反馈 start-->
            <div class="popup" id="feedback" style="font-size: 16px;">
                <div class="head"> 意见反馈
                    <del>×</del>
                </div>
                <div class="body">
                    <div class="scroll" style="transform: translate3d(0px, 0px, 0px) scale(1);">
                        <div class="list">
                            <label class="item">
                                <textarea id="yjfk" placeholder="请输入您的意见或建议，帮助我们提供更高的服务体验" rows="6" style="width: 500px;"></textarea>
                            </label>

                            <label class="padding" style="text-align: center;">
                                <button class="button blue" onclick="addSuggestion();">提交</button>
                            </label>
                        </div>
                    </div>
                    <h3>我的意见反馈</h3>
                    <div>
                        <table border="0" class="table bordered center zebra" style="width: 550px;word-wrap:break-word;word-break:break-all;">
                            <thead>
                            <tr class="strong">
                                <td>状态</td>
                                <td>提交时间</td>
                                <td>反馈内容</td>
                                <td>回复意见</td>
                                <td>操作</td>
                            </tr>
                            </thead>
                            <tbody id="feedbackList">
                            <!--<tr>-->
                                <!--<td>未读</td>-->
                                <!--<td>2017-11-24 17:13:43</td>-->
                                <!--<td>XXXXXXXXXXXXXXX</td>-->
                                <!--<td><a href="#">删除</a></td>-->
                            <!--</tr>-->
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <!--意见反馈 end-->

        </div>
    </div>
</div>
<div class="footer" style="background:#ffffff url(imgs/loginbg2.jpg) repeat-x;height: 150px;">
    <p></p>
</div>
</body>
<script type="text/javascript">
    var G_SERVICEADDR = "",G_DEBUGMOUDE=false;
    if(window.location.host.indexOf('192.168.191.3')>=0||window.location.host.indexOf('localhost')>=0){
        G_DEBUGMOUDE = true;
        //G_SERVICEADDR = "http://192.168.191.1:8080";
        G_SERVICEADDR = "/cross";
    }

    var OpenAPI = {
        "loginUrl": G_DEBUGMOUDE?(G_SERVICEADDR+"/itsm-mobile/auth"):"/itsm-mobile/auth",
        "updateUrl": G_DEBUGMOUDE?(G_SERVICEADDR+"/itsm17/mobile/picture/upload"):"/itsm17/mobile/picture/upload",
        "updateActionUrl": G_DEBUGMOUDE?(G_SERVICEADDR+"/itsm17/uploadAction/upload"):"/itsm17/uploadAction/upload",
        "requrl": G_DEBUGMOUDE?(G_SERVICEADDR+"/mobile/api"):"/mobile/api",
        "getCommentUrl": G_DEBUGMOUDE?(G_SERVICEADDR+'/itsm17/workorder/opinion/getByOrderId?orderId='):"/itsm17/workorder/opinion/getByOrderId?orderId=",
        "saveCommentUrl": G_DEBUGMOUDE?(G_SERVICEADDR+'/itsm17/workorder/opinion/save'):"/itsm17/workorder/opinion/save",
        "getRemindMeUrl": G_DEBUGMOUDE?(G_SERVICEADDR+"/itsm17/remind/my"):"/itsm17/remind/my",
        "setRemindMeUrl": G_DEBUGMOUDE?(G_SERVICEADDR+"/itsm17/remind/send"):"/itsm17/remind/send",
        "suggestionMyUrl": G_DEBUGMOUDE?(G_SERVICEADDR+"/itsm17/suggestion/my"):"/itsm17/suggestion/my",
        "suggestionSaveUrl": G_DEBUGMOUDE?(G_SERVICEADDR+"/itsm17/suggestion/save"):"/itsm17/suggestion/save",
        "Loginout": G_DEBUGMOUDE?(G_SERVICEADDR+"/user/Login!out.do"):"/user/Login!out.do",
        "suggestionDeleteUrl": G_DEBUGMOUDE?(G_SERVICEADDR+"/itsm17/suggestion/delete"):"/itsm17/suggestion/delete"
    };

    var GetQueryString = function(name) {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    };

    var G_GDList = [];
    var G_GDDetail = [];
    var G_RemindList = [];
    var G_type = {
        'SERVICEREQ_CATEGORY_10':'桌面支持服务',
        'SERVICEREQ_CATEGORY_20':'会议支持服务',
        'SERVICEREQ_CATEGORY_40':'应用系统服务',
        'SERVICEREQ_CATEGORY_50':'其他服务'
    };
    var wjx_s = "★";
    var wjx_k = "☆";
    var Store = {};

    Store.saveObject=function(key, object) {
        window.localStorage[key] = JSON.stringify(object);
    };

    Store.loadObject=function(key) {
        var objectString = window.localStorage[key];
        return objectString == null ? null : JSON.parse(objectString);
    };

    Store.deleteObject=function(key) {
        window.localStorage[key] = null;
    };

    Store.clear=function() {
        window.localStorage.clear();
    };

    var Session={};

    Session.saveObject=function(key, object) {
        window.sessionStorage[key] = JSON.stringify(object);
    };

    Session.loadObject=function(key) {
        var objectString = window.sessionStorage[key];
        return objectString == null ? null : JSON.parse(objectString);
    };

    Session.deleteObject=function(key) {
        window.sessionStorage[key] = null;
    };

    $(function () {
        //1. 给所有的li注册mouseenter事件
        $("#fwtComment li,#gcsComment li").mouseenter(function () {
            //2. 让当前li和前面所有的li变成实心,让后面所有的兄弟变成空心
            //前面兄弟：prevAll()：
            //后面兄弟：nextAll()：
            $(this).text(wjx_s).prevAll().text(wjx_s);
            $(this).nextAll(wjx_k);
        });
        //2. 离开ul的时候，把所有的li变成空心
        $("#fwtComment,#gcsComment").mouseleave(function () {
            $(this).children().text(wjx_k);
            //如果我知道了我刚刚点了那个五角星
            //可以让点的那个五角星以及前面的兄弟变成实心就可以。
            //4. 找到我点击的那个li
            $("li.licurrent").text(wjx_s).prevAll().text(wjx_s)
        });
        //3. 给所有的li注册点击事件，点击的时候，留下点东西(class)
        $("#fwtComment li,#gcsComment li").click(function () {
            $(this).addClass("licurrent").siblings().removeClass("licurrent")
        });

        $(".pjbutton").click(function(){
            $(this).addClass("active").siblings().removeClass("active");
            $("#pjnr").val($(this).html());
        });

        $("input[name=category]").click(function(){
            var typename = $(this).val();
//            console.log(typename);
            switch (typename){
                case 'SERVICEREQ_CATEGORY_20':
                case 'SERVICEREQ_CATEGORY_10':
                    $("#description").attr('placeholder','请描述您所选择的服务请求的具体信息。');
                    $('#descriptionAddress').removeClass('hide');
                    $('#addressTitle').removeClass('hide');
                    break;
                case 'SERVICEREQ_CATEGORY_50':
                case 'SERVICEREQ_CATEGORY_40':
                    $("#description").attr('placeholder','请描述您所选择的服务请求的具体信息以及用户所在办公地点。');
                    $('#descriptionAddress').addClass('hide');
                    $('#addressTitle').addClass('hide');
                    break;
                default:
            }
        });

        $('del').click(function(){
            $(this).parent().parent().addClass('hide');
        });

        //获取授权信息
        getAuthInfo();
    });

    //初始化文件上传
    var uploader = new plupload.Uploader({
        runtimes : 'html5,flash,silverlight,html4',
        browse_button : 'pickfiles', // you can pass an id...
        container: document.getElementById('container'), // ... or DOM Element itself
        url : OpenAPI.updateActionUrl,
        flash_swf_url : '../js/Moxie.swf',
        silverlight_xap_url : '../js/Moxie.xap',

        filters : {
            max_file_size : '10mb',
            mime_types: [
                {title : "Image files", extensions : "jpg,gif,png"},
                {title : "doc files", extensions : "zip,doc,docx,xls,xlsx,pdf,rar,txt"}
            ]
//            prevent_duplicates : true //不允许选取重复文件
        },
        file_data_name:"uploadFile",

        init: {
            PostInit: function() {
                document.getElementById('filelist').innerHTML = '请选择需要上传的文件...';
            },

            FilesAdded: function(up, files) {
                if(files.length>1) { // 最多上传3张图
                    alert("只能上传一个附件，请删除多余文件！");
                    return false;
                }

                if( !!window._pp_imageId ){
                    delUploadFile();
                }

                plupload.each(files, function(file) {
                    document.getElementById('filelist').innerHTML = '<div id="' + file.id + '">' + file.name + ' <b></b></div>';
                    window._pp_imageId = file;
                    up.start();
                });
            },

            FilesRemoved: function(up, files) {
                // Called when files are removed from queue
                window._pp_imageId = '';
                window._dd_imageId = '';
                document.getElementById('filelist').innerHTML = '请选择需要上传的文件...';
            },

            UploadProgress: function(up, file) {
                document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
            },

            FileUploaded: function(up, file, info) {
                var rep = $.parseJSON(info.response.match(/\{(.+?)\}/g)[0]);
                window._dd_imageId = rep.attachmentId;
                document.getElementById('filelist').innerHTML = '<a target="_blank" id="' + file.id + '" href="'+rep.url+'">' + rep.fileName +
                        '</a> <b onclick="delUploadFile();">X</b>';
//                console.log('[FileUploaded] File:', file, "Info:", info);
            },

            Error: function(up, err) {
                var msg = '';
                switch (err.code){
                    case -100:
                        msg = "通用错误!";
                        break;
                    case -200:
                        msg = "网络错误!";
                        break;
                    case -300:
                        msg = "磁盘读写错误!";
                        break;
                    case -400:
                        msg = "因为安全问题而产生的错误!";
                        break;
                    case -500:
                        msg = "初始化时发生错误!";
                        break;
                    case -600:
                        msg = "选择的文件太大!";
                        break;
                    case -601:
                        msg = "文件类型不符合要求!";
                        break;
                    case -602:
                        msg = "当选取了重复的文件!";
                        break;
                    case -700:
                        msg = "发生图片格式错误!";
                        break;
                    case -701:
                        msg = "发生内存错误!";
                        break;
                    case -702:
                        msg = "文件大小超过了程序所能处理的最大值!";
                        break;
                }
                alert("错误 #" + err.code + ": " + msg);
            }
        }
    });


    function reloadPage(){
        window.location.reload();
    }

    //获取用户登录信息
    function getAuthInfo(){


        if(G_DEBUGMOUDE){
            //用户名密码授权登录
            //用户名密码授权登录
//            var username = '53119';
            var username = '53120';
            var pwd = '654321';

            var reqdata = {
                'method' : 'login',
                'param' : JSON.stringify({username:username, pwd: pwd})
            };

            postData(OpenAPI.requrl, $.param(reqdata), function(data) {
                if( data.code == 200 ){
                    var usertype = data.object.usertype;
                    username = data.object.username;
                    usertype = data.object.usertype;
                    Session.saveObject("user", data.object);
                    Session.saveObject("usertype", usertype);
                    Store.saveObject("cacheusername",username);

                    FwqqListCtrl();
                }else{
                    alert(data.message);
                }
            },true);
        }else{
            //var _data= {'code':200,'result':true,'userObject':{"message":"","object":{"username":"43225","shizhuren":false,"email":"43225@Any3.com","sessionId":"DB31F576FF778BB004290B9285725F62","department":"管理创新与IT中心","name":"张慧波(Ella Zhang)","userid":"43225","replyPermission":false,"usertype":"0","mobile":"13708329853"},"code":200}}

            //token授权登录
            var token = GetQueryString('token');
            var reqdata = {
//                token: token
            };
            postData(OpenAPI.loginUrl, $.param(reqdata), function(_data){
                if( _data.code == 200 ) {
                    var data = _data.userObject;
                    var usertype = data.object.usertype;
                    var username = data.object.username;

                    Session.saveObject("user", data.object);
                    Session.saveObject("usertype", usertype);
                    Store.saveObject("cacheusername", username);

                    FwqqListCtrl();
                }else{
                    alert(_data.message);
                }
            },true);
        }
    }

    // 服务请求列表
    function FwqqListCtrl(){
        var p = {
            //"type" : "ServiceReq",
            "type" : "mobileRequest",
            "dbtype":'0'
        };
        var reqdata = {
            'method' : 'OrderList',
            'param' : JSON.stringify(p),
            'fromType': 'weixin'
        };

        var scrollItems = [];
        var hasdata = true;

        var cacheusername = Store.loadObject("cacheusername");
        var expiredTime = 48*60*60*1000;

        postData(OpenAPI.requrl, $.param(reqdata), function(data) {
            var str='';
            G_GDList = data.object;
            if( !G_RemindList.length ){
                getRemindList();
            }
            for (var i = 0; i < data.object.length; i++) {
                var obj = data.object[i];
                str += '<tr><td>' + obj.serialno + '</td><td>' + obj.title + '</td><td>' + obj.gendate + '</td><td>' + obj.currentHandlerName + '</td><td>' + obj.statuname + '</td><td><a href="#" rel="popup" onclick="showDetail('+i+')">查看</a>&nbsp;';
                for (var j=0;j<G_RemindList.length;j++){
                    if( obj.serialno == G_RemindList[j].serialNo ){
                        str += '<a href="#" onclick="remindMe(\''+obj.serialno+'\')">催单</a>&nbsp;';
                        break;
                    }
                }
                if (obj && obj.endDate && obj.endDate > 0) {
                    if (obj.hasOpinion) {
                        str += '<a href="#checkEvaluate" rel="popup" onclick="showCheckEvaluate(\''+obj.serialno+'\')">查看评价</a></td></tr>';
                    } else if (obj.starterLoginId == cacheusername && ((new Date()).getTime() - obj.endDate) <= expiredTime) {
                        str += '<a href="#evaluate" rel="popup" onclick="showEvaluate(\''+obj.serialno+'\');">我要评价</a></td></tr>';
                    }
                }
            }

            $('#detailList').html(str);
            if (data.object.length == 0) {
//                $scope.hasdata = false;
            }
        },true);
    }

    function showDetail(index){
        if( G_GDList.length ){
            var obj = G_GDList[index];
            $('#gdTitle').html(obj.title||"");
            $('#gdID').html(obj.serialno||"");
            $('#gdState').html(obj.statuname||"");
            $('#gdUser').html(obj.currentHandlerName||"");
            $('#gdDepartment').html(obj.department||"");
            $('#gdTel').html(obj.gdTel||"");
            $('#gdEmail').html(obj.email||"");
//            $('#gdContent').html(obj.description+(!!obj.remark1?"<br/><br/>"+obj.remark1:""));

            getGDListDetail(obj.serialno);
        }
    }

    function getGDListDetail (id){
        var p = {
            "serialno" : id
        };

        var reqdata = {
            'method' : 'OrderQuery',
            'param' : JSON.stringify(p)
        };

        postData(OpenAPI.requrl, $.param(reqdata), function(data){
            if(data.code == 200){
                var obj = data.object,str='<li><h3>处理过程</h3></li>';
                for ( var i=0;i<obj.deal_process.length;i++){
                    str += '<li>'+obj.deal_process[i].submit_info+'<br/>'+obj.deal_process[i].execute_date;
                }

                $('#gdProcess').html(str);

                $('#gdContent').html(obj.description+(!!obj.remark1?"<br/><br/>"+obj.remark1:""));

                //图片
                if(obj.image) {
                    $('#wexinDownloadImg').attr('src',obj.image);
                    $('#wexinDownloadImg').parent().removeClass('hide');
                }else {
                    $('#wexinDownloadImg').attr('src','');
                    $('#wexinDownloadImg').parent().addClass('hide');
                }

                //附件
                var string = '';
                if( obj.attachments.length && !obj.image ){
                    for (var m = 0; m< obj.attachments.length;m++){
                        string += '<a href="'+obj.attachments[m].map.url+'" target="_blank">'+obj.attachments[m].map.name+'</a><br/>';
                    }
                }
                $('#packeg').html(string);

                $('#alertDetail').addClass('alertShow').css('display','block').removeClass('hide');
//                $('#alertDetail').addClass('alertShow').css('display','block').css('top','50');
            }else{
                alert(data.message);
            }
        },true);
    }

    function getRemindList(){
        postData(OpenAPI.getRemindMeUrl, "", function(data){
            G_RemindList = data.list;
        },false);
    }

    function remindMe (id) {
        if( !G_RemindList.length ){
            getRemindList();
        }
        if( !G_RemindList.length ){
            alert('数据获取异常!');
            return;
        }

        for ( var i=0;i<G_RemindList.length;i++ ){
            console.log(G_RemindList[i].serialNo + ' '+id);
            if( G_RemindList[i].serialNo == id ){
                var reqdata = {
                    'nodeLsh' : G_RemindList[i].nodeLsh,
                    'flowLsh' : G_RemindList[i].flowLsh,
                    'serialNo': G_RemindList[i].serialNo
                };
                postData(OpenAPI.setRemindMeUrl, $.param(reqdata), function(data){
                    if( data.result ){
                        alert("催单成功");
                    }else{
                        alert(data.message);
                    }
                });
                break;
            }
        }
    }

    function showAddGd (){
        var userInfo = Session.loadObject("user");
        $('#addUser').html(userInfo.name||"");
        $('#addTel').html(userInfo.mobile||"");
        $('#addEmail').html(userInfo.email||"");
        $('#addDepartment').html(userInfo.department||"");

        $('#addNew').addClass('alertShow').css('display','block').css('top','50').removeClass('hide');
        uploader.init();
    }

//    function uploadFile (e){
//        var me = this;
//        var file=e.files[0];
//        if(file){
//            var fd = new FormData();
////            fd.append("image",file);
//            fd.append("uploadFile",file);
//
//            $.ajax({
//                url: OpenAPI.updateActionUrl,
//                type: "POST",
//                processData: false,
//                contentType: false,
//                data: fd,
//                success: function(res){
//                    // 转成json格式
//                    var data = JSON.parse(res);
//                    if(data && data.result){
//                        window._pp_imageId = data.attachmentId;
//                        $('#wexinUploadImg').attr('href', data.url).html(data.fileName);
//                        $('#wexinUploadImgContainer').css('display', 'block');
//                    }
//                },
//                error: function(){
//                    alert('文件上传失败!');
//                }
//            });
//        }
//    }

    function delUploadFile (){
        uploader.removeFile(window._pp_imageId);
//        $('#wexinUploadImg').attr('href', '').html('');
//        $('#wexinUploadImgContainer').css('display', 'none');
    }

    function subGd (){
        var category = $("input[name=category]:checked").val();
        var title = $("input[name=category]:checked").attr('title');
        var description = $("#description").val();
        var descriptionAddress = $("#descriptionAddress").val();
        var fileID = window._dd_imageId;

        if (category == undefined || category == '') {
            alert("输入错误,请选择服务请求类型!");
            return;
        }
        if (description == undefined || description == '') {
            alert("输入错误,请输入信息描述!");
            return;
        }
        if(category=='SERVICEREQ_CATEGORY_20'||category=='SERVICEREQ_CATEGORY_10') {
            if (descriptionAddress == undefined || descriptionAddress == '') {
                alert("输入错误,请输入地址信息描述!");
                return;
            }
        }

        if( category == 'SERVICEREQ_CATEGORY_50' || category == 'SERVICEREQ_CATEGORY_40'){
            $("#descriptionAddress").val('');
        }

        var paramdata = {
            title : G_type[category],
            category: category,
            description : description,
            majorevent:"N"
        };
//        if ($scope.formData.majorevent == true) {
//            paramdata.majorevent = "Y";
//        } else {
//            paramdata.majorevent = "N";
//        }
        var reqdata = {
            'method' : 'ServiceReqDispatch',
            'remark1': descriptionAddress||'',
            'param' : JSON.stringify(paramdata),
//            'weixinPhotoId': $scope.formData.weixinPhotoId, //'1rctdO_G1F97xF9AUx6ZbcksMVkD3EoiGll3tKC22Dao',
//            'dataFrom' : 'weixin',
            'attachmentId': fileID
        };

        //alert(JSON.stringify(paramdata))
        //return;

        postData(OpenAPI.requrl, $.param(reqdata), function(data){
            alert("新增服务请求成功");
            window.location.reload()
        });
    }

    //获取意见反馈列表
    function getSuggestionList (){

        postData(OpenAPI.suggestionMyUrl, "", function(data){
            var  str="";
            for (var i = 0; i < data.list.length; i++) {
                var obj = data.list[i];
                obj.commentTitle = (obj.status === "未读")?'<a href="#" onclick="delSuggestion(\''+obj.id+'\');">删除</a>':'';
                //替换代码里面的空格然后解码
                obj.reply = decodeURIComponent(decodeURI(obj.reply.replace(/%2B/g," ")));
                //obj.reply = obj.reply || "暂无回复内容";
                obj.content = decodeURIComponent(decodeURI(obj.content.replace(/%2B/g," ")));

                str += '<tr><td>'+obj.status+'</td><td>'+obj.dateTime+'</td><td>'+obj.content+'</td><td>'+obj.reply+'</td><td>'+obj.commentTitle+'</td></tr>';
            }
            $('#feedbackList').html(str);
        });

        $('#feedback').addClass('alertShow').css('display','block').css('top','50').removeClass('hide');
    }

    function delSuggestion(id){
        var r=confirm("你确定要删除该条记录?");
        if (r==true){
            var reqdata = {
                'id' : id
            };
            postData(OpenAPI.suggestionDeleteUrl, $.param(reqdata), function(data){
                if( data.result ){
                    alert("删除成功");
                    setTimeout(function(){
                        getSuggestionList();
                    },500);
                }else{
                    alert(data.message);
                }
            });
        }
    }

    function addSuggestion(){
        var suggestion =$('#yjfk').val();
        if (suggestion == undefined || suggestion == '') {
            alert("输入错误,请输入您的反馈意见!");
            return false;
        }
        var reqdata = {
            'content' : suggestion
        };
        postData(OpenAPI.suggestionSaveUrl, $.param(reqdata), function(data){
            if( data.result ){
                alert("您的意见已经成功反馈!");
                $('#yjfk').val("");
                setTimeout(function(){
                    getSuggestionList();
                },500);
            }else{
                alert(data.message);
            }
        });
    }

    function showEvaluate(id){
        $('#fwtComment li').eq(3).addClass('licurrent').siblings().removeClass("licurrent");
        $('#fwtComment li').eq(3).text(wjx_s).prevAll().text(wjx_s);

        $('#gcsComment li').eq(3).addClass('licurrent').siblings().removeClass("licurrent");
        $('#gcsComment li').eq(3).text(wjx_s).prevAll().text(wjx_s);

        $('#subPj').attr('gdId',id);
        $('#evaluate').addClass('alertShow').css('display','block').removeClass('hide');
    }

    function  subEvaluate(){
        var content = $('#pjnr').val();
        var user = Session.loadObject("user");
        var grade = 0,serviceGrade = 0;
        if(content==undefined || content.trim() ==""){
            alert('输入错误,请输入内容描述!');
            return;
        }

        if( $('#fwtComment .licurrent').length > 0 ){
            grade = $('#fwtComment .licurrent').prevAll().length +1;
        }else{
            grade = 0;
        }

        if( $('#gcsComment .licurrent').length > 0 ){
            serviceGrade = $('#gcsComment .licurrent').prevAll().length +1;
        }else{
            serviceGrade = 0;
        }
        var p = {
            "userid" : user.userid,
            "username" : user.name
        };
        var reqdata = {
            'method' : 'NoteAdd',
            'param' : JSON.stringify(p),
            "content" : content,
            "workOrderId": $('#subPj').attr('gdId'),
            "grade": grade,
            "serviceGrade": serviceGrade
        };

//        console.log(reqdata);

        postData(OpenAPI.saveCommentUrl, $.param(reqdata), function(data){
            alert("提交成功");
            setTimeout(function(){
                window.location.reload();
            },500);
        });
    }

    function showCheckEvaluate(id){
        postData(OpenAPI.getCommentUrl + id, {}, function(data){
            if( data.code == 200 ){
                $('#fwtCommentView li').eq(data.data.grade-1).addClass('licurrent').siblings().removeClass("licurrent");
                $('#fwtCommentView li').eq(data.data.grade-1).text(wjx_s).prevAll().text(wjx_s);

                $('#gcsCommentView li').eq(data.data.serviceGrade-1).addClass('licurrent').siblings().removeClass("licurrent");
                $('#gcsCommentView li').eq(data.data.serviceGrade-1).text(wjx_s).prevAll().text(wjx_s);

                $('#pjnrView').html(data.data.content);
                $('#checkEvaluate').addClass('alertShow').css('display','block').removeClass('hide');
            }
        },true);
    }

    function loginOut(){
        if(confirm('确认要退出系统吗?')){
            window.location.href = "/user/Login!out.do";
        }else{
            return false;
        }
    }

    function postData (url, data, callback,sync){
        $.ajax({
            data:data,
            type: "POST",
            async: sync,
            url: url,
            dataType: "json",
            callback:'json_callback',
            scriptCharset:"utf-8",
            success: function (returnData) {
                if (callback) {
                    callback(returnData || {});
                }
            },
            error: function () {
                alert('获取数据异常!');
            }
        });
    }

</script>
</html>
